package cn.yuanqiao.web.controller.archive.fondsFolder;

import cn.yuanqiao.archive.fondsFolder.domain.FondsFolder;
import cn.yuanqiao.archive.fondsFolder.domain.Model;
import cn.yuanqiao.archive.fondsFolder.service.FondsFolderService;
import cn.yuanqiao.common.web.controller.BaseController;
import cn.yuanqiao.common.core.domain.AjaxResult;
import cn.yuanqiao.common.web.page.TableDataInfo;
import cn.yuanqiao.common.annotation.Log;
import cn.yuanqiao.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/archive/fondsFolder")
public class FondsFolderController extends BaseController {
    @Autowired
    private FondsFolderService fondsFolderService;

    @GetMapping("/list")
    @Log(title = "大事记/组织沿革模板查询", businessType = BusinessType.SELECT)
    public TableDataInfo list(Model model)
    {
        String isPage = String.valueOf(model.getParams().get("isPage"));
        if(!"no".equals(isPage)){
            startPage();
        }
        List<Model> list = fondsFolderService.selectModelList(model);
        return getDataTable(list);
    }

    /**
     * 删除大事记/组织沿革模板管理
     */
    @Log(title = "大事记/组织沿革模板删除", businessType = BusinessType.DELETE)
    @DeleteMapping("/{IDs}")
    public AjaxResult remove(@PathVariable String[] IDs)
    {
        return toAjax(fondsFolderService.deleteModelByIDs(IDs));
    }


    /**
     * 查询【请填写功能名称】列表
     */
    @GetMapping("/listTab")
    @Log(title = "大事记/组织沿革查询", businessType = BusinessType.SELECT)
    public TableDataInfo list(FondsFolder bjyqFondsfolder)
    {
        //startPage();
        List<FondsFolder> list = fondsFolderService.selectFondsfolderList(bjyqFondsfolder);
        return getDataTable(list);
    }


    /**
     * 获取【请填写功能名称】详细信息
     */
    @GetMapping(value = "/tab/{ID}")
    @Log(title = "大事记/组织沿革明细查询", businessType = BusinessType.SELECT)
    public AjaxResult getInfo(@PathVariable("ID") String ID)
    {
        return success(fondsFolderService.selectFondsfolderByID(ID));
    }

    /**
     * 新增【请填写功能名称】
     */
    @Log(title = "大事记/组织沿革添加", businessType = BusinessType.INSERT)
    @PostMapping("/tab")
    public AjaxResult add(@RequestBody FondsFolder bjyqFondsfolder)
    {
        return toAjax(fondsFolderService.insertFondsfolder(bjyqFondsfolder));
    }

    /**
     * 修改【请填写功能名称】
     */
    @Log(title = "大事记/组织沿革修改", businessType = BusinessType.UPDATE)
    @PutMapping("/tab")
    public AjaxResult edit(@RequestBody FondsFolder bjyqFondsfolder)
    {
        return toAjax(fondsFolderService.updateFondsfolder(bjyqFondsfolder));
    }

    /**
     * 删除【请填写功能名称】
     */
    @Log(title = "大事记/组织沿革删除", businessType = BusinessType.DELETE)
    @DeleteMapping("/tab/{IDs}")
    public AjaxResult remove(@PathVariable String IDs)
    {
        return toAjax(fondsFolderService.deleteFondsfolderByID(IDs));
    }

    @Log(title = "保存大事记/组织沿革模板", businessType = BusinessType.INSERT)
    @PostMapping("/saveModel/{id}")
    public AjaxResult saveModel(@PathVariable("id") String id)
    {
        String s = fondsFolderService.saveModel(id);
        return success(s);
    }
}
